<?php

class Pay {

	public function run() {
		if (empty($_GET['appPath']) || empty($_GET['server']) || empty($_GET['method'])) {
			return;
		}
		list($plugin, $ver) = explode('.', $_GET['appPath']);

		$f = ROOT_PATH . '/www/' . $plugin . '/' . $ver . '/servers/' . $_GET['server'] . '.php';
		define('PLUGIN_PATH', ROOT_PATH . '/www/' . $plugin . '/' . $ver . '/');
		if (!file_exists($f)) {
			return;
		}
		$class = $_GET['server'] . 'Pay';
		$method = $_GET['method'];

		try {
			require $f;
			$c = new $class();
			$return = call_user_func_array([$c, $method], $_GET['params']);
		} catch (Exception $e) {
			return false;
		};

		$c = new Controller();
		$c->showMessage('', 0, $return);
	}
}